﻿using MediatR;
using S_Gridding.Api.Application.Commands.MeshType;
using S_Gridding.Infrastructure.Interface.IWrite;

namespace S_Gridding.Api.Application.CommandsHanders.MeshTypeHanders
{
    /// <summary>
    /// 中介者模式单个真删除网格类型管理表
    /// </summary>
    public class MeshTypeSqlSuageTrueDeleteCommandHander : IRequestHandler<MeshTypeSqlSuageTrueDeleteCommand, int>
    {
        private readonly IMeshTypeRepository _meshTypeRepository;  //网格类型管理表仓储接口

        public MeshTypeSqlSuageTrueDeleteCommandHander(IMeshTypeRepository meshTypeRepository)
        {
            _meshTypeRepository = meshTypeRepository;
        }

        /// <summary>
        /// 中介者模式单个真删除网格类型管理表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> Handle(MeshTypeSqlSuageTrueDeleteCommand request, CancellationToken cancellationToken)
        {
            var res = await _meshTypeRepository.GetFindAsync(request.MeshTypeId);
            return await _meshTypeRepository.DeleteAsync(res);

        }
    }
}
